from time import process_time
from traceback import print_tb


def test(num):
    print("-" * 50)
    print(f"{num} 在函数内的内存地址是 {id(num)}")

    result = 100

    print(f"返回值 {result}在内存中的地址是 {id(result)}")

    return result

# a = 10
# print(f"调用函数前内存地址是 {id(a)}")
#
# r = test(a)
#
# print(f"调用函数后 实参内存地址是 {id(a)}")
# print(f"调用函数后 返回值内存地址是 {id(r)}")
#
# print("#" * 50)
# demo_list = [1, 2, 3]
# demo_list.append(4)
# print(demo_list)
# demo_list.append(5)
# print(demo_list)
# demo_list.remove(3)
# print(demo_list[1])

# demo_list = [1, 2, 3]
#
# print("定义列表后的内存地址 %d" % id(demo_list))
#
# demo_list.append(999)
# demo_list.pop(0)
# demo_list.remove(2)
# demo_list[0] = 10
#
# print("修改数据后的内存地址 %d" % id(demo_list))
#
# demo_dict = {"name": "小明"}
#
# print("定义字典后的内存地址 %d" % id(demo_dict))
#
# demo_dict["age"] = 18
# demo_dict.pop("name")
# demo_dict["name"] = "老王"
#
# print("修改数据后的内存地址 %d" % id(demo_dict))

class Game(object):
    #游戏最高分， 类属性
    top_score = 0

    @staticmethod
    def show_help():
        print("帮助信息：让僵尸走进房间")

    @classmethod
    def show_top_score(cls):
        print(f"游戏最高分是{cls.top_score}")

    def __init__(self, player_name):
        self.player_name = player_name

    def start_game(self):
        print(f"{self.player_name} 开始游戏...")

        #使用类名. 修改历史最高分
        Game.top_score = 999

# # 1.查看游戏帮助
# Game.show_help()
#
# # 2.查看游戏最高分
# Game.show_top_score()
#
# # 3.创建游戏对象，开始游戏
# game = Game("小明")
# game.start_game()
#
# # 4.游戏结束，查看游戏最高分
# Game.show_top_score()



############### 装饰器 #################
def w1(func):
    """装饰器函数"""
    def inner():
        func()
        print("这是添加的功能")
    return inner

@w1
def f1():
    """业务函数1"""
    print("------1------")

@w1
def f2():
    """业务函数2"""
    print("------2------")
# f1()
# f2()
import os
# print(os.getcwd())
# print(os.name)
# print(os.environ)
# print(os.environ.get("PATH"))
# print(os.sep)

def recursion_file_catalogue(path, indent=0, maxi=-1):
    """
    按字典序递归输出目录结构
    :param path: str 文件路径
    :param indent: int 首次缩进空格（默认为0，一般不能改变）
    :param maxi: int 最大展开层数（默认为-1，表示全部展开）
    :return: 文件目录
    """
    if maxi != 0:
        try:
            lsdir = os.listdir(path)
        except PermissionError:
            pass
        else:
            for item in lsdir:
                full_path = os.path.join(path, item)
                if os.path.isdir(full_path):
                    print(' ' * indent, '+', item)
                    recursion_file_catalogue(full_path, indent + 4, maxi - 1)
                if os.path.isfile(full_path):
                    print(' ' * indent, '-', item)

if __name__ == "__main__":
    file_path = r'E:\kubeasc'
    recursion_file_catalogue(file_path, 0, 2)